class Solution:
    def maxArea(self, height: list[int]) -> int:
        ans, left, right = 0, 0, len(height) - 1
        while left < right:
            ans = max(min(height[left], height[right]) * (right - left), ans)
            if height[left] > height[right]:
                right -= 1
            else:
                left += 1
        return ans
